package com.yumi.service.impl;

import com.yumi.dao.PetDao;

import com.yumi.dao.PetDaoOracleImpl;
import com.yumi.service.PetService;
import com.yumi.entity.Pet;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

@Service("petService")
public class PetServiceImpl implements PetService {
    @Resource(type = PetDaoOracleImpl.class)
     private PetDao petDao ;

    @Override
    public boolean save(Pet pet) {
        int rows = petDao.insert(pet);
        delay(3000);
        return rows > 0;
    }

    private void delay(int timei) {
        try {
            Thread.sleep(timei);
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
    }

    @Override
    public boolean modify(Pet pet) {
        delay(2000);
        return false;
    }

    @Override
    public boolean del(Integer id) {
        delay(1000);
        return false;
    }
}
